package com.yonyou.pmclouds.visitcard.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yonyou.pmclouds.ApplicationConsts;
import com.yonyou.pmclouds.basecom.annotation.Insert;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.visitcard.entity.VisitCardVO;
import com.yonyou.pmclouds.visitcard.rmiitf.VisitCardMaintain;
import com.yonyou.pmclouds.visitcard.rmiitf.VisitCardQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/mobile/visitcard")
public class VisitCardController {

    @Reference(version = ApplicationConsts.APPLICATION_VERSION)
    private VisitCardMaintain maintain;
    @Reference(version = ApplicationConsts.APPLICATION_VERSION)
    private VisitCardQuery visitCardQuery;

    @Insert
    @RequestMapping("/insert")
    @ResponseBody
    public VisitCardVO insert(@RequestBody VisitCardVO vo) throws BusinessException {
        vo = maintain.insert(vo);
        return this.queryById(vo.getPkVisitcard());
    }

    @GetMapping("/{id}")
    public VisitCardVO queryById(@PathVariable String id) throws BusinessException {
        return visitCardQuery.queryById(id);
    }
}
